//
//  BJInvestmentView.m
//  SZBank
//
//  Created by rimi on 16/7/11.
//  Copyright © 2016年 LuoYao. All rights reserved.
//

#import "BJInvestmentView.h"

@interface BJInvestmentView ()<CustomerNavigationBarsDelegate>
{
    NSArray *viewArray;/**< 存放view的名字 */
}
@property (nonatomic)CustomerNavigationBars *kingNavigation;/**< 导航button */
@property (nonatomic)KingView *king;/**< 金石榴投资理财 */
@property (nonatomic)TrustView *trust;/**< 信托 */
@property (nonatomic)InvestmentGoodsView *investmentGoods;/**< 信托 */
@property (nonatomic)InsuranceVIew *insurance;/**< 保险 */
@property (nonatomic)RiskAppraisalView *riskAppraisal;/**< 风险测评 */

@end
@implementation BJInvestmentView



- (instancetype)initWithFrame:(CGRect)frame
{
    

    self = [super initWithFrame:frame];
    if (self) {
       

 
        
        UIImageView *backGround = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, self.frame.size.width , self.frame.size.height )];
        backGround.image = [UIImage imageNamed:@"背景"];
        [self addSubview:backGround];
        
        UIView *lineView = [[UIView alloc]initWithFrame:CGRectMake(self.frame.size.width * 0.05, CGRectGetMaxY(self.kingNavigation.frame) + 1, self.frame.size.width * 0.9, 1)];
        lineView.backgroundColor = [UIColor blackColor];
        [self addSubview:lineView];/**< 添加线条 */
        
        [self addSubview:self.kingNavigation];/**< 添加导航按钮 */
        
        self.userInteractionEnabled = YES;
        [self addSubview:self.king];/**< 默认加载的视图 */
        
    }
    return self;
}

#pragma mark -- inits

#pragma mark -- CustomerNavigationBarsDelegate 
- (void)customeNavigationBarView:(CustomerNavigationBars *)customeNavigationBarView didSelectButton:(UIButton *)didSelectButton{
  
    viewArray = [NSArray array];
    //存入数组
    viewArray = @[self.king, self.trust, self.riskAppraisal, self.investmentGoods,self.insurance];
    // 循环移除视图
    
    
    for (int i = 0;i < viewArray.count; i++   ) {
        [viewArray[i] removeFromSuperview];
    }
    
    
    switch (didSelectButton.tag - 1000) {
        case 0:{
                self.king = nil;
                [self addSubview:self.king];
            
        }
            break;
        case 1 :{
                self.trust = nil;
                [self addSubview:self.trust];

        }
            break;
        case 2:{
                self.investmentGoods = nil;
                [self addSubview:self.investmentGoods];
           
        }
            break;
        case 3:{
                self.insurance = nil;
                [self addSubview:self.insurance];
            
        }
            break;
        case 4:{
                self.riskAppraisal = nil;
                [self addSubview:self.riskAppraisal];
                    
                }
                break;
        default:
            break;
   
    }
}
#pragma mark -- BtnClick


#pragma mark -- getters
            
- (KingView *)king{
    if (!_king) {
        _king = [[KingView alloc]initWithFrame:CGRectMake(self.frame.size.width * 0.05, CGRectGetMaxY(self.kingNavigation.frame) + KHEIGHT * 0.01, self.frame.size.width * 0.9, self.frame.size.height - self.kingNavigation.frame.size .height - KHEIGHT * 0.02)];

    }
    return _king;
}

- (CustomerNavigationBars *)kingNavigation{
    if (!_kingNavigation) {
        NSArray *titleArray = @[@"金石榴理财",@"信托",@"投资品",@"保险",@"风险测评"];
        _kingNavigation = [[CustomerNavigationBars alloc]initWithFrame:CGRectMake(0, 0, self.frame.size.width, KHEIGHT * 0.06) btnTitleArray:titleArray];
        _kingNavigation.delegate = self;
        
    }
    return _kingNavigation;
}
- (TrustView *)trust{
    if (!_trust) {
        _trust = [[TrustView alloc]initWithFrame:CGRectMake(self.frame.size.width * 0.05, CGRectGetMaxY(self.kingNavigation.frame) + KHEIGHT * 0.01, self.frame.size.width * 0.9, self.frame.size.height - self.kingNavigation.frame.size .height - KHEIGHT * 0.02)];

    }
    return _trust;
}

- (InvestmentGoodsView *)investmentGoods{
    if (!_investmentGoods) {
        _investmentGoods = [[InvestmentGoodsView alloc]initWithFrame:CGRectMake(self.frame.size.width * 0.05, CGRectGetMaxY(self.kingNavigation.frame) + KHEIGHT * 0.01, self.frame.size.width * 0.9, self.frame.size.height - self.kingNavigation.frame.size .height - KHEIGHT * 0.02)];
  

    }
    return _investmentGoods;
}
- (InsuranceVIew *)insurance{
    if (!_insurance) {
        _insurance = [[InsuranceVIew alloc]initWithFrame: CGRectMake(self.frame.size.width * 0.05, CGRectGetMaxY(self.kingNavigation.frame) + KHEIGHT * 0.01, self.frame.size.width * 0.9, self.frame.size.height - self.kingNavigation.frame.size .height - KHEIGHT * 0.02)];


    }
    return _insurance;
}
- (RiskAppraisalView *)riskAppraisal{
    _riskAppraisal = [[RiskAppraisalView alloc]initWithFrame:CGRectMake(self.frame.size.width * 0.05, CGRectGetMaxY(self.kingNavigation.frame) + KHEIGHT * 0.01, self.frame.size.width * 0.9, self.frame.size.height - self.kingNavigation.frame.size .height - KHEIGHT * 0.02)];
 
 
    return _riskAppraisal;
}
@end
